const db = require('../db/index');

exports.stressAnalysis = (req, res) => {
  const userId = req.user.id;
  // 这里需要实现日程密度分析和任务优先级调整逻辑
  const sql = 'SELECT COUNT(*) as count FROM schedules WHERE user_id = ? AND start_time BETWEEN CURDATE() AND CURDATE() + INTERVAL 1 DAY';
  db.query(sql, [userId], (err, results) => {
    if (err) return res.cc(err);
    const scheduleCount = results[0].count;
    let stressLevel = '正常';
    if (scheduleCount > 5) {
      stressLevel = '高压';
    }
    res.send({
      status: 0,
      message: '压力分析成功',
      data: {
        scheduleCount,
        stressLevel
      }
    });
  });
};